package com.yuebook.reader.service.user;

import com.sun.org.apache.regexp.internal.RE;
import com.yuebook.reader.common.param.user.UserParamBean;
import com.yuebook.reader.common.vo.user.UserInfo;
import com.yuebook.reader.dao.user.UserInfoDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author honglei
 * @date 2018/10/31 下午8:24
 */
@Service
public class UserServiceImpl implements UserService {

    private Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);

    @Autowired
    private UserInfoDao userInfoDao;

    @Override
    public UserInfo getUserById(Integer id) {
        return userInfoDao.getUserById(id);
    }

    @Override
    public Integer addUser(UserParamBean userParamBean) {
        UserInfo userInfo = new UserInfo();
        BeanUtils.copyProperties(userParamBean, userInfo);
        userInfoDao.addUser(userInfo);
//        logger.info(String.valueOf(userInfo.getId()+3));
        return userInfo.getId();
    }
}
